package Lab05.Q5;

public abstract class Vehicle {
    static int nums;
    int wheels;

    public Vehicle() {
        this(0);
        nums++;
    }

    public Vehicle(int wheels) {
        this.wheels = wheels;
        nums++;
    }

    void setWheels(int wheels) {
        if (wheels > 4||wheels <0)
            System.out.println("请输入符合规则的数字！！！");
        else
            this.wheels =wheels;
    }
    int getWheels(){
        return this.wheels;
    }

}

class Motorbike extends Vehicle {
    private Person driver;
    private Person passenger;
    public Motorbike(int wheels) {
        super(wheels);
    }
    void setDriver(Person driver) {
        this.driver = driver;
    }
    Person getDriver() {
        return this.driver;
    }
    void setPassenger(Person passenger){
        this.passenger=passenger;
    }
    Person getPassenger() {
        return this.passenger;
    }
    public String toString() {
        return "This motorbike has " + this.getWheels() + " wheels.\n"
                + "The driver is " + driver.getName() + " and the passenger is "+ passenger.getName()
                + ".\nThe passenger says: " + passenger.say();
    }

}

class Car extends Vehicle {
    public Car(int wheels) {
        super(wheels);
    }
}

class Tank extends Vehicle {
    public Tank(int wheels) {
        super(wheels);
    }
}
